package unittest;

import org.junit.Test;

import treeedit.Main;

public class MainTest {
	@Test
	public void testPrintUsage() {
		Main.printUsage();
	}

	public void generateSmallTree(String filepath) {
		Main.main(new String[] { "-g", "-o", filepath, "-f", "2", "-l", "3", "-s", "2",
				"-n", "15" });
	}

	public void generateMediumTree(String filepath) {
		Main.main(new String[] { "-g", "-o", filepath, "-f", "6", "-l", "4", "-s", "3",
				"-n", "20" });
	}

	public void randomizeTreesABit(String i_filepath, String o_filepath,
			String o_filepath_2) {
		Main.main(new String[] { "-r", "-o", o_filepath, "-c", "20", "-i", i_filepath });
		Main.main(new String[] { "-r", "-o", o_filepath_2, "-c", "20", "-i", i_filepath });
	}

	public void randomizeTreesALot(String i_filepath, String o_filepath,
			String o_filepath_2) {
		Main.main(new String[] { "-r", "-o", o_filepath, "-c", "80", "-i", i_filepath });
		Main.main(new String[] { "-r", "-o", o_filepath_2, "-c", "80", "-i", i_filepath });
	}

	@Test
	public void testRunGenerateTree() {
		generateSmallTree("file1.txt");
	}

	@Test
	public void testRunRandomizeTree() {
		generateSmallTree("file1r.txt");
		randomizeTreesABit("file1r.txt", "file1ra.txt", "file1rb.txt");
	}

	@Test
	public void testRunGenerateTreeDeep() {
		Main.main(new String[] { "-g", "-o", "fileDeep.txt", "-f", "3", "-l", "10", "-s",
				"2", "-n", "10" });
	}

	@Test
	public void testRunTED() {
		generateSmallTree("firstTree.txt");
		randomizeTreesABit("firstTree.txt", "firstTreeA.txt", "firstTreeB.txt");
		Main.main(new String[] { "-t", "-i", "firstTreeA.txt", "firstTreeB.txt" });
	}

	@Test
	public void testRunTEDwithBBF() {
		generateSmallTree("firstTree.txt");
		randomizeTreesABit("firstTree.txt", "firstTreeA.txt", "firstTreeB.txt");
		Main.main(new String[] { "-b", "-i", "firstTreeA.txt", "firstTreeB.txt", "-t",
				"5" });
	}
}